/**
 * 
 */
package com.jolestar.yayaweibotong;

import java.io.IOException;

/**
 * @author jolestar@gmail.com
 * 
 */
public class NetworkException extends YayaException {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7111970840710454045L;

	public NetworkException(Throwable cause) {
		super("网络异常" + getIOExceptionMessage(cause), cause);
	}

	/**
	 * @param message
	 * @param cause
	 */
	public NetworkException(String message, Throwable cause) {
		super(message, cause);
	}

	private static String getIOExceptionMessage(Throwable cause) {
		if (cause == null) {
			return "";
		}
		if (cause instanceof IOException) {
			return cause.getMessage();
		} else {
			return getIOExceptionMessage(cause.getCause());
		}
	}

}
